function f_show_zhuanpan(){
		//弹框
    	var _html2 = '<div class="pop-lot" id="J_pop_lot">'+
	        '<a href="javascript:;" class="close"></a>'+
	        '<div id="Lottery" class="s">'+
	            '<a href="javascript:;" class="btn"></a>'+
	        '</div>'+
	        '<div class="list-lucky" id="J_list_lucky">'+
	            '<ul style="margin-top: 0px;">'+
	            str_repeat('<li><img src="" alt="" /><p class="name"></p><p class="info">抽中<strong></strong></p></li>',20)+
	            '</ul>'+
	        '</div>'+
	        '<div class="task-share"></div>'+
	        '<a href="javascript:void(0);" class="task2"></a>'+
	        '<a href="javascript:void(0);" class="btn-overtask">去分享&gt;&gt;</a>'+
	        '<a href="javascript:void(0);" class="task-record"></a>'+
	        '</div>';
		$("#pop-content").html(_html2);
		openpop();
		//获奖用户
		$.ajax({
    		url: $(".page_url").val()+"?c=common2&m=AjaxZhuanPanAwardUser",
    		dataType: "json",
    		success: function(rs){
    			fusion2.ui.hideMsgbox();
    			var _html3 = '';
    			$.each(rs,function(i,n){
    				_html3 += '<li><img src="'+n.figureurl+'" alt="'+n.nickname+'">'+
				              	  '<p class="name">'+n.nickname+'</p>'+
				              	  '<p class="info">抽中<strong>'+n.award+'</strong></p>'+
				              '</li>';
    			});
    			$("#J_pop_lot").find("ul").html(_html3);
    		}
    	});
		
		//------------------begin获奖名单滚动---------------------//
        var oListLucky = $("#J_list_lucky"),
            timeout_listlucky = null;

    	var btn_PopLot = false;
        
        if(oListLucky.find("li").length > 1){
            function scrollListLucky(){
                oListLucky.find("ul").stop(true).animate({
                    "marginTop":"-60px"
                },600,function(){
                    oListLucky.find("ul").css({
                        "marginTop":0
                    });
                    oListLucky.find("li:first").insertAfter(oListLucky.find("li:last"));
                })
            }
            timeout_listlucky = setInterval(scrollListLucky,3000);
            oListLucky.find("ul").live("mouseover",function(){
                $(this).stop(true).css({
                    "marginTop":0
                });
                clearInterval(timeout_listlucky);
            }).live("mouseout",function(){
                timeout_listlucky = setInterval(scrollListLucky,3000);
            })
        }
      //------------------end获奖名单滚动---------------------//
}
//-----------------------------------字符串复制---------------------------------//
function str_repeat (input, multiplier) {
  var y = '';
  while (true) {
    if (multiplier & 1) {
      y += input;
    }
    multiplier >>= 1;
    if (multiplier) {
      input += input;
    }
    else {
      break;
    }
  }
  return y;
}

var _USER_AWARD_STEP = 0;
$(function(){
	//页面地址
	var __PAGEURL = $(".page_url").val()+"?c=common2&";
    /* 抽奖 start */
    (function(){
    	//弹框
    	f_show_zhuanpan();
    	//变量
        var count = 8,
            oTime_1 = oTime_2 = null,
            oKey = true,
            random = parseInt(Math.random()*5 + 3),
            speed = parseInt(Math.random()*80 + 30),
            stop = random * speed*8;
        /*--------------开始转--------------*/
        function countFun(){
            if(count < 8){
                return ++count;
            }else{
                count = 1;
                return count;
            }
        }
        $("#Lottery").find(".btn").live("click",function(){//点击转盘
        	if(_USER_AWARD_STEP>1){
        		popTipLot(0,"你今天没有抽奖机会啦，记得明天再来~",_USER_AWARD_STEP);
        		oKey = true;
        		return false;
        	}
        	//第1、2次转盘
            if(oKey && _USER_AWARD_STEP<=1){
                oKey = false;
                random = parseInt(Math.random()*5 + 3),
                speed = parseInt(Math.random()*80 + 30),
                stop = random*speed*8;
                //抽奖结果
                $.ajax({
            		type: "get",
            		url: __PAGEURL+"m=AjaxChouJiangJieGuo",//抽奖结果
            		data: "step="+_USER_AWARD_STEP+"&",
            		dataType:"json",
            		success: function(rs){
            			fusion2.ui.hideMsgbox();
            			//转动代码
                        oTime_1 = setInterval(function(){
                        	$("#Lottery").attr("class","s s" + countFun());
                        },speed);
                        setTimeout(function(){
                            oTime_2 = setInterval(function(){
                                if(count == rs.prize){
                                    clearInterval(oTime_2);
                                    clearInterval(oTime_1);
                                    oKey = true;
                                    
                                    _USER_AWARD_STEP++;
                                    
                                    //第一次在upin中抽奖显示的提示窗
                                    popTipLot(rs.type,rs.msg,_USER_AWARD_STEP);
                                    //第二次在upin中抽奖显示的提示窗
                                    //popTipLot(1,'还差一点点就中奖了，明天记得再来哦~');
                                }
                            },speed);
                        },stop);
            		}
                });
            }
        });
        
        //点击“我的获奖记录”
    	$("#J_pop_lot").find(".task-record").live('click',function(){
    		$.ajax({
        		type: "get",
        		url: __PAGEURL+"m=AjaxUserChouJiangJieGuo",
        		dataType:"json",
        		success: function(rs){
        			fusion2.ui.hideMsgbox();
        			//我的抽奖结果
        			if(rs.ret<0){
        				fusion2.ui.showMsgbox({type: 3,msg: "信息错误，请重登",timeout: 1000});
        				return false;
        			}
        			popTipLot(rs.tiptype, rs.msg, 100);
        		}
            });
    	});
    	
    	//点击“去分享”
    	$(".btn-overtask").live("click",function(){
    		$("#J_pop_lot").hide();
            $("#mask").hide();
    	})
        
		// -----------------------------------弹窗---------------------------------//
        // @param 0 表示第一种弹窗
        // @param 1 表示第二种弹窗
        // @param str 弹窗内容
        function popTipLot(style,str,step){
            var html = '';
            if(style == 0){ 
                if($(".pop-lot-record").length > 0){
                    $(".pop-lot-record").remove();
                }
                html += '<div href="javascript:;" class="pop-lot-record">'+ str +'</div>';
                setTimeout(function(){
                    $(".pop-lot-record").remove();
                },1500)
            }else if(style ==1){
                if($(".pop-lot-boot").length > 0){
                    $(".pop-lot-boot").remove();
                }
                html += '<div class="pop-lot-boot">';
                html += '<div class="inner">';
                html += '<p>'+ str +'</p>';
                html += '<div class="btn-outer">';
                html += '<a href="javascript:;" class="btn-sure"></a>';
                html += '</div>';
                html += '</div>';
                html += '</div>';
            }
            $(".pop-lot").append(html);
            btn_PopLot = true;
            $(".pop-lot-boot").find(".btn-sure").live("click",function(){
            	//step 100 我的获奖列表
            	if(step!=100){
            		if(_USER_AWARD_STEP==1){
    	            	$(this).parents(".pop-lot-boot").eq(0).remove();
    	                $(".pop-lot").addClass("pop-lot-task-youpin");
    	                btn_PopLot = false;
    	                oKey = true;
                	}
                	if(_USER_AWARD_STEP>=2){
                		$("#J_pop_lot").hide();
                        $("#mask").hide();
                	}
        			//清除结果
                	$("#Lottery").attr("class","s");
            	}else{
            		$(this).parents(".pop-lot-boot").eq(0).remove();
            	}
            })
        }
    })()
    /* 抽奖 end */	
    
})